﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmetic.Logic;

namespace WebApp.Management.Product
{
	public partial class RecommendProList : PageBase2
	{
        private PlateManager PM = new PlateManager();
        private RoleManager m_RoleManager = new RoleManager();
		protected void Page_Load(object sender, EventArgs e)
		{
            if (this.SignInUser1 == null)
            {
                Session.Remove("SignInUser1");
                this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('请先登录权限!');window.top.location.href='/Management/indexs.aspx';", true);
                return;
            }
            if (!IsPostBack)
            {
                Cosmetic.DataEntity.User theUser = this.SignInUser1;
                if (!this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Admin))
                {
                    Session.Remove("SignInUser1");
                    this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('你没有管理员权限!');window.top.location.href='/Management/indexs.aspx';", true);
                    return;
                }
            }
            if (!IsPostBack)
            {
                this.ListView1.DataSource = PM.GetPlateCosmeticProducts2();
                this.ListView1.DataBind();
            }
		}

        protected void lvActivity_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Cosmetic.DataEntity.PlateJapaneseCosmetic theOne = PM.GetPlateJapaneseCosmetic(Convert.ToInt32(e.CommandArgument.ToString()));
            if (e.CommandName.Equals("OnDelete"))
            {
                PM.DeletePlateCosmeticProtudct(theOne);
                this.ListView1.DataSource = PM.GetPlateCosmeticProducts2();
                this.ListView1.DataBind();
            }
        }
	}
}